﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace ALDIOrganizer
{    
    /* This class encapsulates specific date-Time functions our application needs */
    public static class Time
    {
        public static Weekday[] AllWeekdays
        {
            get
            {
                return new[]
                {
                    Weekday.Monday,
                    Weekday.Tuesday,
                    Weekday.Wednesday,
                    Weekday.Thursday,
                    Weekday.Friday,
                    Weekday.Saturday,
                    Weekday.Sunday
                };
            }
        }       

        public static Weekday ToWeekday(DayOfWeek pDayOfWeek)
        {
            if (pDayOfWeek == DayOfWeek.Sunday)
            {
                return Weekday.Sunday;
            }
            var i = (int)pDayOfWeek;
            return (Weekday)(i - 1);
            
        }

        public static string NameOfDay(Weekday w)
        {
            return Program.CurrentCulture.DateTimeFormat.GetDayName(w.ToDayOfWeek());
        }

        public static string NameOfDay(int i)
        {
            var _w = (Weekday)i;
            return NameOfDay(_w);
        }

        public static string ShortDayName(int pI)
        {
            return Program.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(((Weekday)pI).ToDayOfWeek());
        }

        public static string ShortNameOfDay(int pColumn)
        {
            var dow = default(DayOfWeek);
            if (pColumn == 1)
            {
                dow = DayOfWeek.Monday;
            }
            else
            if (pColumn < 7)
            {
                dow = (DayOfWeek)pColumn;
            }
            if (pColumn == 7)
            {
                dow = DayOfWeek.Sunday;
            }
            return Program.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(dow);
        }

        
    }
}
